using System;
using System.Reflection;
using SQLRunnerLib.Util;

namespace SQLRunnerCommand
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class MainClass
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static int Main(string[] args)
		{
			foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) {
			    if (assembly.FullName != null)
			        if (assembly.FullName.StartsWith("SQLRunnerCommand")) {
			            Console.WriteLine(string.Format("SQL Server Runner - [{0}]",
			                                            assembly.GetName().Version));
			            break;
			        }
			}
			Console.WriteLine(@"http://www.codeplex.com/sqlrunner");
		    LineParser parser = new LineParser(args);
			LineController controller = new LineController();
			int returnValue = controller.Start(parser);
			if ( (parser.ErrorLevel & ErrorIndicator.AppFailure) == ErrorIndicator.AppFailure ) 
			{
				return returnValue;
			}
			return 0;
		}
	}
}
